$(function () {
    cleanFormValid();
});
function cleanFormValid() {
    $("#cleanForm").validate({
        rules: {
            b_cleanName: {
                required: true,
                minlength: 3,
                isCode:true
            },
            b_cleanCode: {
                required: true,
                minlength: 3,
            },
            b_rowSort:{
                required: true,
                isDigits: true
            }
        },
        errorPlacement: function(error, element) {
            error.appendTo(element.parent());
        },
        errorElement: "span",
        errorClass: "errortips errortips-w200",
        success: 'valid',
        messages: {
            b_cleanName: {
                required: " (必填)",
                minlength: " (不能少于 3 个字母)",
            },
            b_cleanCode: {
                required: " (必填)",
                minlength: " (不能少于 3 个字母)",
            },
            b_rowSort:{
                required: " (必填)",
                isDigits: "输入正整数"
            }
        },
    });
}

function submitForm() {
    if($('#cleanForm').valid()){
        return false;
    }
    return {};
}

jQuery.validator.addMethod("isCode", function(value, element) {
    return this.optional(element) || /^[A-Z]{3}[0-9]{4}$/.test($("#b_deviceCode").val());
},'请输入3位大写字母＋4位数字');

